//
//  XZHDayAndNightFunctionTableViewCell.m
//  Piece
//
//  Created by dllo on 16/6/21.
//  Copyright © 2016年 Northeast Dianli University. All rights reserved.
//

#import "XZHDayAndNightFunctionTableViewCell.h"
#import "JXLDayAndNightMode.h"

@implementation XZHDayAndNightFunctionTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
        switchView.onTintColor = [UIColor colorWithRed:0.46 green:0.75 blue:0.96 alpha:1.00];
        if (JXLDayAndNightModeDay == [[JXLDayAndNightManager shareManager] contentMode]) {
            switchView.on = NO;
        } else {
            switchView.on = YES;
        }
        self.accessoryView = switchView;
        [switchView addTarget:self action:@selector(switchValueChange:) forControlEvents:UIControlEventValueChanged];
        
    }
    
    return self;
}

- (void)switchValueChange:(UISwitch *)switchView {
    if (switchView.on) {
        [[JXLDayAndNightManager shareManager] nightMode];
    } else {
        [[JXLDayAndNightManager shareManager] dayMode];
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
